package com.longg.utils;

import com.longg.comm.Comm;

public class PageUtil {
    public static long getTotalPage(long count){
        return count % Comm.PAGE_SIZE == 0 ? count / Comm.PAGE_SIZE : count / Comm.PAGE_SIZE + 1;
    }

    public static long getStartPage(long currentPage){
        return currentPage % Comm.PAGE_COUNT == 0 ? currentPage - Comm.PAGE_COUNT + 1 : (currentPage - currentPage % Comm.PAGE_COUNT) + 1;
    }

    public static long getEndPage(long currentPage,long count){
        long startPage = getStartPage(currentPage);
        return startPage + Comm.PAGE_COUNT - 1 < getTotalPage(count) ? startPage + Comm.PAGE_COUNT - 1 : getTotalPage(count);
    }
}
